package guda.house.web.action;

import guda.grape.util.RequestUtil;
import guda.house.biz.beans.vo.JsonResult;
import guda.house.biz.constants.CommonResultCode;
import guda.house.biz.util.ErrorCode;
import guda.house.biz.util.PriceUtil;
import guda.house.web.helper.ResponseHelper;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by well on 15/11/20.
 */
@Controller
public class CommonAction {

    @RequestMapping(value = "rmb.htm", method = RequestMethod.GET)
    public void rmb(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) {
        long price = RequestUtil.getLong(request,"p");
        JsonResult result = JsonResult.getInstance();
        if(price == 0){
            result.setErrMsg(ErrorCode.getMessage(CommonResultCode.PARAM_MISS));
            ResponseHelper.ajaxReturn(result.getMap(), response);
            return;
        }
        result.getMap().put("p", PriceUtil.formatCNY(price));
        ResponseHelper.ajaxReturn(result.getMap(), response);
        return;
    }
}
